/*
 * Copyright (C) 2017 yixun All Rights Reserved.
 * 
 * CommissionRulesDto.java
 */
package com.yixun.qfbao.model.dto;

import com.yixun.qfbao.model.CommissionRules;
import com.yixun.qfbao.model.Company;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * [文件名称]<br>
 * CommissionRulesDto.java<br>
 * <br>
 * [文件描述]<br>
 * 佣金规则表 数据辅助类<br>
 * <br>
 * [修改记录]<br>
 * 2017-10-18 18:27:59 创建 陶俊代码生成器<br>
 * 
 * @author 陶俊代码生成器
 * @version 1.00
 */
public class CommissionRulesDto extends CommissionRules {
	private static final long serialVersionUID = 1L;
	/**
	 *需要正序字段名
	 */
	private List<String> asc;
	/**
	 *需要逆序字段名
	 */
	private List<String> desc;
	/**
	 *排序SQL
	 */
	private String orders;

	//楼盘id
	private Long premisesId;

	//合作机构id
	private List<Company> cooperations;

	private String ruleString;
	private List<RuleDto> rules;

	private String company;

	private Long subRuleId;

	private Date beginTime;

	private Date endTime;

    /**
	 *  添加需要正序字段名
	 */
	public void addAsc(String col){
		if(asc==null){
			asc = new LinkedList<String>();
		}
		asc.add(col);
	}
	
	/**
	 *  清空需要正序字段名
	 */
	public void cleanAsc(){
		asc = null;
	}
	
	/**
	 *  添加需要逆序字段名
	 */
	public void addDesc(String col){
		if(desc==null){
			desc = new LinkedList<String>();
		}
		desc.add(col);
	}
	
	/**
	 *  清空需要逆序字段名
	 */
	public void cleanDesc(){
		desc = null;
	}
	
	/**
	 *  如果排序SQL为空根据需要正逆序的字段名拼接排序SQL
	 */
	public String  getOrders() {
		StringBuilder orderStr = null;
		StringBuilder ascStr;
		StringBuilder descStr;
		if(orders==null){
			if(asc!=null){
				ascStr = new StringBuilder();
				orderStr = new StringBuilder();
				String pex = "";
				for(String a : asc){
					ascStr.append(pex+a);
					pex = ",";
				}
				orderStr.append(ascStr.toString()+" ASC");
			}
			if(desc!=null){
				descStr = new StringBuilder();
				String pex = "";
				for(String d : desc){
					descStr.append(pex+d);
					pex = ",";
				}
				if(orderStr==null){
					orderStr = new StringBuilder();
					orderStr.append(descStr.toString()+" DESC");
				}else{
					orderStr.append(","+descStr.toString()+" DESC");
				}
			}
			orders = orderStr!=null?orderStr.toString():null;
		}
		
		return orders;
	}
	
	/**
	 *  设置排序SQL
	 */
	public void setOrders(String orders) {
		this.orders = orders;
	}
	private Date lostTimeBefore;
	private Date lostTimeAfter;
	private Date updateTimeBefore;
	private Date updateTimeAfter;
	private Date createTimeBefore;
	private Date createTimeAfter;
	private Date effectTimeBefore;
	private Date effectTimeAfter;
	private String premisesName;//楼盘名称
	private String companyName;//公司名称
    public String getPremisesName() {
		return premisesName;
	}

	public void setPremisesName(String premisesName) {
		this.premisesName = premisesName;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public Date getLostTimeBefore() {
        return this.lostTimeBefore;
    }
    public void setLostTimeBefore(Date lostTimeBefore) {
        this.lostTimeBefore = lostTimeBefore;
    }

    public Date getLostTimeAfter() {
        return this.lostTimeAfter;
    }
    public void setLostTimeAfter(Date lostTimeAfter) {
        this.lostTimeAfter = lostTimeAfter;
    }
    public Date getUpdateTimeBefore() {
        return this.updateTimeBefore;
    }
    public void setUpdateTimeBefore(Date updateTimeBefore) {
        this.updateTimeBefore = updateTimeBefore;
    }

    public Date getUpdateTimeAfter() {
        return this.updateTimeAfter;
    }
    public void setUpdateTimeAfter(Date updateTimeAfter) {
        this.updateTimeAfter = updateTimeAfter;
    }
    public Date getCreateTimeBefore() {
        return this.createTimeBefore;
    }
    public void setCreateTimeBefore(Date createTimeBefore) {
        this.createTimeBefore = createTimeBefore;
    }

    public Date getCreateTimeAfter() {
        return this.createTimeAfter;
    }
    public void setCreateTimeAfter(Date createTimeAfter) {
        this.createTimeAfter = createTimeAfter;
    }
    public Date getEffectTimeBefore() {
        return this.effectTimeBefore;
    }
    public void setEffectTimeBefore(Date effectTimeBefore) {
        this.effectTimeBefore = effectTimeBefore;
    }

    public Date getEffectTimeAfter() {
        return this.effectTimeAfter;
    }
    public void setEffectTimeAfter(Date effectTimeAfter) {
        this.effectTimeAfter = effectTimeAfter;
    }

	public Long getPremisesId() {
		return premisesId;
	}

	public void setPremisesId(Long premisesId) {
		this.premisesId = premisesId;
	}

	public List<Company> getCooperations() {
		return cooperations;
	}

	public void setCooperations(List<Company> cooperations) {
		this.cooperations = cooperations;
	}

	public List<RuleDto> getRules() {
		return rules;
	}

	public void setRules(List<RuleDto> rules) {
		this.rules = rules;
	}

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public String getRuleString() {
		return ruleString;
	}

	public void setRuleString(String ruleString) {
		this.ruleString = ruleString;
	}

	public Long getSubRuleId() {
		return subRuleId;
	}

	public void setSubRuleId(Long subRuleId) {
		this.subRuleId = subRuleId;
	}

	public Date getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
}
